<template>
	<view>
		<view class="search">
			<input type="text" v-model="sousuo" placeholder="请输入订单号、货物名称、装卸地、日期" />
			<view @click="kaishishous()">搜索</view>
		</view>
		<view class="container">
			<view class="current">
				<view class="current_top">
					<view class="fl">我的运单</view>
					<view class="fr">
						<text>全部</text>
						<image src="../../static/iocn11.png"></image>
					</view>
				</view>
				<view class="current_box">
					<view :class="navIndex==0?'active':''" @click="checkIndex(0)">
						<image src="../../static/iocn19.png"></image>
						<text>付订金</text>
					</view>
					<view :class="navIndex==1?'active':''" @click="checkIndex(1)">
						<image src="../../static/iocn20.png"></image>
						<text>运输中</text>
					</view>
					<view :class="navIndex==2?'active':''" @click="checkIndex(2)">
						<image src="../../static/iocn21.png"></image>
						<text>待结算</text>
					</view>
					<view :class="navIndex==3?'active':''" @click="checkIndex(3)">
						<image src="../../static/iocn22.png"></image>
						<text>已结算</text>
					</view>
					<view :class="navIndex==4?'active':''" @click="checkIndex(4)">
						<image src="../../static/iocn23.png"></image>
						<text>订单取消</text>
					</view>
					<!-- <view>
						<u-modal :show="show" :showCancelButton="true" @confirm="confirm" @cancel="cancel" title="确认报价" :content='content'></u-modal>
					</view> -->
				</view>
			</view>

			<!-- 付定金 -->
			<view v-if="navIndex==0">
				<view class="success" v-for="(item,index) in lista" :key="item.id">
					<view class="success_top">
						<view class="fl">
							<view class="viewtop">付定金</view>
							<view class="viewkey">{{item.waybillNumber}}</view>
							<view class="viewbox" @click.stop="paste(item)">复制</view>
						</view>
						<view class="fr">{{item.creationTime}}</view>
					</view>
					<view class="success_key">
						<view class="viewtop">
							<text>{{item.shipZone}}</text>
							<image src="../../static/iocn4.png"></image>
							<text>{{item.receiveZone}}</text>
						</view>
						<view class="viewbox">
							<text>货物信息：{{item.goodsName}} / {{item.goodsWeight}}T / {{item.goodsSize}}m³ /{{item.goodsPackagMethod}}</text>
								
							<text>车辆信息：{{item.lesscarload}} / {{item.demandLoad}}T / {{item.demandLength}} /{{item.demandStyle}} </text>
								
						</view>
					</view>
					<view class="success_one">
						<view class="success_top">
							<text>总运费:</text>
							<input type="number" v-model="item.amountTotal" :disabled="disabled"></input>
							<text class="yuan">元</text>
							<image src="../../static/iocn44.png"></image>
							<text @click="xiugaiyunfei(item)">点击修改</text>
						</view>
						<view class="success_body">
							<text>订&#12288;金:</text>
							<input type="number" v-model="item.deposit" :disabled="disabled"></input>
							<text class="yuan">元</text>
							<text v-if="item.returnDeposit == true">(可退还)</text>
							<text v-else>(不可退还)</text>
							<image src="../../static/iocn44.png"></image>
							<text @click="xiugaidinjin(item)">点击修改</text>
						</view>
						<p v-if="item.returnDeposit == true">（订金支付至平台通宝，货主确认收货后由平台立即退还）</p>
						<p v-else></p>
						<p @click="dakai()">展开查看详情 ></p>
					</view>
					<view class="success_sj">
						<image src="../../static/iocn8.png"></image>
						<view class="success_sjs">
							<text>货主: {{item.receiveContact}}</text>
							<image src="../../static/iocn27.png"></image>
							<text @click="dakailianxi(item)">联系货主</text>
						</view>
					</view>
					<view class="success_box">
						<view class="viewtop" @click="CreateTrade(item)">付订金</view>
						<!-- 	<view @click.stop="WayBillCancel(item)">取消运单</view> -->
					</view>
				</view>
				<view v-if="lista == 0">
					<u-empty mode="message" icon="http://cdn.uviewui.com/uview/empty/message.png"></u-empty>
				</view>

			</view>

			<!-- 运输中 -->
			<view v-if="navIndex==1">
				<view class="success" v-for="(item,index) in listb">
					<view class="success_top">
						<view class="fl">
							<view class="viewtop">运输中</view>
							<view class="viewkey">{{item.waybillNumber}}</view>
							<view class="viewbox" @click.stop="paste(item)">复制</view>
							
						</view>
						<view class="fr" @click="wzhankai(index)">
							<text>展开详情</text>
							<image src="../../static/iocn14.png" v-if="navindexnav == index"></image>
							<image src="../../static/iocn12.png" v-else></image>
						</view>
					</view>
					<view class="success_key">
						<view class="viewtop">
							<text>{{item.shipZone}}</text>
							<image src="../../static/iocn4.png"></image>
							<text>{{item.receiveZone}}</text>
						</view>
						<view class="viewbox">
							<text>货物信息：{{item.goodsName}} / {{item.goodsWeight}}T / {{item.goodsSize}}m³ /{{item.goodsPackagMethod}}</text>
								
							<text>车辆信息：{{item.lesscarload}} / {{item.demandLoad}}T / {{item.demandLength}} /{{item.demandStyle}} </text>
								
						</view>
					</view>
					<view v-if="navindexnav == index">
						<view class="descrip_top">
							<view class="box_box">装</view>
							<view class="descr_box">
								<text v-if="item.shipCompany=='null'">个体经营</text>
								<text v-else>{{item.shipCompany}}</text>
								<text>{{item.shipAddress}}</text>
							</view>
						</view>
						<view class="descrip_top">
							<view class="box_key">卸</view>
							<view class="descr_box">
								<text v-if="item.receiveCompany==''">个体经营</text>
								<text v-else>{{item.receiveCompany}}</text>
								<text>{{item.receiveAddress}}</text>
							</view>
						</view>
						<view class="warn" @click="bohao(item)">
							<image src="../../static/iocn27.png"></image>
							<text class="warnkey">联系货主</text>
							<text>{{item.receiveTelphone}}</text>
						</view>

						<view class="group" v-for="(itema,index) in item.deliveryItems">
							<view class="group_fl">
								<view>{{itema.deliveryStatus}}</view>
								<text>{{itema.creationTime}}</text>
							</view>
							<view class="group_fr">{{itema.remark}}</view>
						</view>
					</view>
					<view class="success_box">
						<view class="viewtop" @click="shangchuan(item.id)">上传回单</view>
						<view class="viewtop" v-if="item.deliveryStatus=='待装货'" @click="genggaiyunshuzhong(item.id,1)">
							已装货</view>
						<view class="viewtop" v-else="item.deliveryStatus!='待装货'"
							@click="genggaiyunshuzhong(item.id,4)">已卸货</view>
					</view>
				</view>

				<view v-if="listb == 0">
					<u-empty mode="message" icon="http://cdn.uviewui.com/uview/empty/message.png"></u-empty>
				</view>
			</view>
			<!-- 待结算 -->
			<view v-if="navIndex==2">
				<view class="success" v-for="(item,index) in listc">
					<view class="success_top">
						<view class="fl">
							<view class="viewtop">待结算</view>
							<view class="viewkey">{{item.waybillNumber}}</view>
							<view class="viewbox" @click.stop="paste(item)">复制</view>
						</view>
						<view class="fr">{{item.creationTime}}</view>
					</view>
					<view class="success_key">
						<view class="viewtop">
							<text>{{item.shipZone}}</text>
							<image src="../../static/iocn4.png"></image>
							<text>{{item.receiveZone}}</text>
						</view>
						<view class="viewbox">
							<text>货物信息：{{item.goodsName}} / {{item.goodsWeight}}T / {{item.goodsSize}}m³ /{{item.goodsPackagMethod}}</text>
								
							<text>车辆信息：{{item.lesscarload}} / {{item.demandLoad}}T / {{item.demandLength}} /{{item.demandStyle}} </text>
								
						</view>
					</view>

					<view class="contact">
						<view class="contact_top">
							<view><text>总运费：</text><text class="viewtop">{{item.amountTotal}}/趟</text></view>
							<view>
								<text>订金：{{item.deposit}}元</text>
								<text class="viewbox" v-if="item.returnDeposit == true">（可退回）</text>
								<text class="viewbox" v-else>（不可退还）</text>
							</view>
						</view>
						<view class="contact_key" v-if="item.returnDeposit == true">（订金支付至平台通宝，货主确认收货后由平台立即退还）</view>
						<view class="contact_key" v-else></view>
					</view>

					<view class="success_box success_bos">
						<view class="viewbot"
							style="border: 1px solid rgba(229, 229, 229, 1);margin-right: 170upx;color: rgba(128, 128, 128, 1);background-color: rgba(229, 229, 229, 1);">
							已上传回单</view>
						<view class="viewtop" @click="dakailianxi(item)">联系货主</view>
					</view>
				</view>
				<view v-if="listc == 0">
					<u-empty mode="message" icon="http://cdn.uviewui.com/uview/empty/message.png"></u-empty>
				</view>
			</view>
			<!-- 已结算 -->
			<view v-if="navIndex==3">
				<view class="success" v-for="(item,index) in listd">
					<image src="../../static/iocn28.png" class="retreat"></image>
					<view class="success_top">
						<view class="fl">
							<view class="viewtop">已结算</view>
							<view class="viewkey">{{item.waybillNumber}}</view>
							<view class="viewbox" @click.stop="paste(item)">复制</view>
						</view>
						<view class="fr">{{item.creationTime}}</view>
					</view>
					<view class="success_key">
						<view class="viewtop">
							<text>{{item.shipZone}}</text>
							<image src="../../static/iocn4.png"></image>
							<text>{{item.receiveZone}}</text>
						</view>
						<view class="viewbox">
							<text>货物信息：{{item.goodsName}} / {{item.goodsWeight}}T / {{item.goodsSize}}m³ /{{item.goodsPackagMethod}}</text>
								
							<text>车辆信息：{{item.lesscarload}} / {{item.demandLoad}}T / {{item.demandLength}} /{{item.demandStyle}} </text>
								
						</view>
					</view>

					<view class="contact">
						<view class="contact_top">
							<view><text>总运费：</text><text class="viewtop">{{item.amountTotal}}/趟</text></view>
							<view>
								<text style="width: 400upx;">订金：{{item.deposit}}元</text>
								<text class="viewbox" v-if="item.returnDeposit == true">（可退回）</text>
								<text class="viewbox" v-else>（不可退还）</text>
								<p @click="ptjr()">联系平台</p>
							</view>
						</view>
					</view>


				</view>
				<view v-if="listd == 0">
					<u-empty mode="message" icon="http://cdn.uviewui.com/uview/empty/message.png"></u-empty>
				</view>
			</view>
			<!-- 订单取消 -->
			<view v-if="navIndex==4">
				<view class="down">
					<view :class="navndex==0?'active':''" @click="checkndex(0)">已成交</view>
					<view :class="navndex==1?'active':''" @click="checkndex(1)">未成交</view>
				</view>
				<view v-if="navndex==0">
					<view v-for="(item,index) in liste">
						<view class="success">
							<view class="success_top">
								<view class="fl">
									<view class="viewtop">已成交</view>
									<view class="viewkey">{{item.waybillNumber}}</view>
									<view class="viewbox" @click.stop="paste(item)">复制</view>
								</view>
								<view class="fr">{{item.creationTime}}</view>
							</view>
							<view class="success_key">
								<view class="viewtop">
									<text>{{item.shipZone}}</text>
									<image src="../../static/iocn4.png"></image>
									<text>{{item.receiveZone}}</text>
								</view>
								<view class="viewbox">
									<text>货物信息：{{item.goodsName}} / {{item.goodsWeight}}T / {{item.goodsSize}}m³ /{{item.goodsPackagMethod}}</text>
										
									<text>车辆信息：{{item.lesscarload}} / {{item.demandLoad}}T / {{item.demandLength}} /{{item.demandStyle}} </text>
										
								</view>
							</view>


							<view class="contact">
								<view class="contact_top">
									<view><text>总运费：</text><text class="viewtop">{{item.amountTotal}}/趟</text></view>
									<view>
										<text style="width: 200upx;">订金：{{item.deposit}}元</text>
										<text class="viewbox" v-if="item.returnDeposit == true">（可退回）</text>
										<text class="viewbox" v-else>（不可退还）</text>
									</view>
								</view>
							</view>

							<view class="seperate">
								<view class="seperate_fl">
									<text v-if="!item.cancelReason == 'null'">取消原因：{{item.cancelReason}}</text>
									<!-- <view>请点击选择</view> -->
								</view>
								<view class="seperate_fr" @click="ptjr()">平台介入</view>
							</view>
						</view>
					</view>
					<view v-if="liste == 0">
						<u-empty mode="message" icon="http://cdn.uviewui.com/uview/empty/message.png"></u-empty>
					</view>
				</view>
				<view v-if="navndex==1">
					<view v-for="(item,index) in listf">
						<view class="success">
							<view class="success_top">
								<view class="fl">
									<view class="viewtop">未成交</view>
									<view class="viewkey">{{item.waybillNumber}}</view>
									<view class="viewbox" @click.stop="paste(item)">复制</view>
								</view>
								<view class="fr">{{item.creationTime}}</view>
							</view>
							<view class="success_key">
								<view class="viewtop">
									<text>{{item.shipZone}}</text>
									<image src="../../static/iocn4.png"></image>
									<text>{{item.receiveZone}}</text>
								</view>
								<view class="viewbox">
									<text>货物信息：{{item.goodsName}} / {{item.goodsWeight}}T / {{item.goodsSize}}m³ /{{item.goodsPackagMethod}}</text>
										
									<text>车辆信息：{{item.lesscarload}} / {{item.demandLoad}}T / {{item.demandLength}} /{{item.demandStyle}} </text>
										
								</view>
							</view>


							<view class="contact">
								<view class="contact_top">
									<view><text>总运费：</text><text class="viewtop">{{item.amountTotal}}元/趟</text></view>
									<view><text>订金：{{item.deposit}}元</text><text class="viewbox"
											v-if="item.returnDeposit == true">（可退还）</text><text class="viewbox"
											v-else>（不可退还）</text></view>
								</view>
							</view>

							<!-- <view class="seperate">
								<view class="seperate_fl">
									<text>取消原因：</text>
									<view>请点击选择</view>
								</view>
								<view class="seperate_fr">平台介入</view>
							</view> -->
						</view>
					</view>
					<view v-if="listf == 0">
						<u-empty mode="message" icon="http://cdn.uviewui.com/uview/empty/message.png"></u-empty>
					</view>
				</view>
			</view>

		</view>

		<!-- 弹窗 -->
		<view class="screenshot" v-show="notification">
			<view class="screenshot_key">
				<uni-icons  type="closeempty" size="30" class="image_top" @click="guanbi()"></uni-icons>
				<view class="screenshot_top">平台介入</view>
				<view class="screenshot_box">
					<text @click="guestbook()">申请后台留言</text>
					<text @click="bodakefu()">拨打客服电话</text>
				</view>
			</view>
		</view>
		<!-- 联系货主弹窗 -->
		<view class="screenshots" v-show="lianxi" @click="guanbilianxi()">
			<view class="screenshot_key">
				<image src="../../static/iocn10.png" class="image_top"></image>
				<uni-icons  type="closeempty" size="30" class="image_gb"></uni-icons>
				<view class="screenshot_top">仅限使用注册号码拨打</view>
				<view class="screenshot_box">{{ shipTelphone}}</view>
				<view class="screenshot_zhen" @click.stop="bohao()">立即拨号</view>
				<view class="screenshot_lis">已为您提供号码保护，支付定金后可查看真实号码</view>
			</view>
		</view>

		<view class="screenshot" v-show="dianjixuanz">
			<view class="screenshot_key">
				<uni-icons  type="closeempty" size="30" class="image_top" @click="guanbi()"></uni-icons>
				<view class="screenshot_list">
					<text>订单未承运</text>
					<view>请确认货物未进行运输</view>
				</view>
				<view class="screensview">
					<view @click="ckndex(1)">
						<text>货主原因</text>
						<image src="../../static/iocn25.png" v-if="nandex == 1"></image>
						<image src="../../static/iocn26.png" v-else></image>
					</view>
					<view @click="ckndex(0)">
						<text>司机原因</text>
						<image src="../../static/iocn25.png" v-if="nandex == 0"></image>
						<image src="../../static/iocn26.png" v-else></image>
					</view>
				</view>
				<input type="text" v-model="reason" placeholder="请输入取消原因" />
				<view class="screeiew" @click="queding()">确认</view>
			</view>
		</view>

		<!-- 订金提示弹窗 -->
		<view class="tancuang" v-show="tancuang">
			<view class="tancuang_key">
				<view class="tancuang_top">
					<view :class="navIndexs==0?'active':''" @click="checkIndexs(0)">可退还</view>
					<view :class="navIndexs==1?'active':''" @click="checkIndexs(1)">不可退还</view>
				</view>
				<view v-show="ketihun">
					<view class="tancuang_lis">
						<view>
							<text class="fl">1</text>
							<text class="fr">司机将订金支付至平台</text>
						</view>
						<view>
							<text class="fl">2</text>
							<text class="fr">货主点击“确认收货”</text>
						</view>
						<view>
							<text class="fl">3</text>
							<text class="fr">平台将订金退还至司机</text>
						</view>
					</view>
					<view class="text">若货主未点击“确认收货”，平台将在您点击“已卸货”后24小时内将订金退还</view>
				</view>


				<view v-show="bketihun">
					<view class="tancuang_lis">
						<view>
							<text class="fl">1</text>
							<text class="fr">司机将订金支付至平台</text>
						</view>
						<view>
							<text class="fl">2</text>
							<text class="fr">货主点击“确认收货”</text>
						</view>
						<view>
							<text class="fl">3</text>
							<text class="fr">平台将订金支付至货主</text>
						</view>
					</view>
					<view class="text">若您未点击“已卸货”，平台将据轨迹在最晚卸货时间24小时后将订金支付给货主</view>
				</view>
				<view class="panel" @click="guanbidingjin()">我知道了</view>
			</view>
		</view>

		<view>
			<Tabbar :current="'0'"></Tabbar>
		</view>
	</view>
</template>

<script>
	import {
		GetWaybillList,
		WayBillCancel,
		CallRecordCreate,
		WayBillReceipt,
		CreateTrade,
		MiniProgramPay,
		TranStatusUpdate,
		UpdateDepFee
	} from '@/public/Api/update.js'
	import {
		setValue,
		getValue
	} from '@/public/storeage/index.js'
	import Tabbar from '@/pages/navigation/sjnavigation.vue';
	export default {
		components: {
			//注册组件
			Tabbar
		},
		data() {
			return {
				lianxi: false,
				navIndex: 0,
				wyincang: true,
				wvheiget: 'none',
				navndex: 0,
				notification: false,
				dianjixuanz: false,
				nandex: 0,
				skipCount: 0,
				maxResultCount: 10,
				navIndexs: 0, //订金提示
				ketihun: true,
				bketihun: false,
				tancuang: false,
				indexnav: 0,
				navindexnav: 50,
				lista: [],
				listb: [],
				listc: [],
				listd: [],
				liste: [],
				listf: [],
				listr: [],
				listt: [],
				payDestination: 2,
				canInvoiced: false,
				reason: '',
				sousuo: '',
				show: false,
				content: '',
				shipTelphone: '',
				wayid: '',
				driverid: "",
				shiperId: '',
				disabled: false,
				userId: '',
			};
		},
		onShow() {
			this.userId =  getValue('id')
			this.daifudingjin() //  我的运单 -- 待确定
		},

		methods: {
			checkIndexs(e) {
				this.navIndexs = e
				var navIndexs = this.navIndexs
				if (navIndexs == 0) {
					this.ketihun = true
					this.bketihun = false
				} else {
					this.ketihun = false
					this.bketihun = true
				}
			},

			dakai() {
				this.tancuang = true
			},

			guanbidingjin() {
				this.tancuang = false
			},
			dakailianxi(e) {
				this.shipTelphone = e.shipTelphone
				this.wayid = e.id
				this.shiperId = e.shiperId
				this.driverid = e.driverId
				this.lianxi = true
			},
			guanbilianxi() {
				this.lianxi = false
			},

			checkIndex(e) {
				console.log(e)
				this.navIndex = e
				var indexnav = e
				if (indexnav == 0) {
					this.daifudingjin() //  我的运单 -- 付定金
				} else if (indexnav == 1) {
					this.yunshuzhong() //  我的运单 -- 运输中
				} else if (indexnav == 2) {
					this.daijiesuan() //  我的运单 -- 待结算
				} else if (indexnav == 3) {
					this.yiwancheng() //  我的运单 -- 已结算
				} else if (indexnav == 4) {
					this.yichengjiao() //  我的运单 -- 订单取消 -- 已成交
				}
			},
			checkndex(e) {
				this.navndex = e
				var indexnav = e
				if (indexnav == 0) {
					this.yichengjiao() //  我的运单 -- 订单取消 -- 已成交
				} else if (indexnav == 1) {
					this.weichengjiao() //  我的运单 -- 订单取消 -- 未成交
				}
			},

			indexkndex(e) {
				this.indexnav = e
				var indexnav = e
				if (indexnav == 0) {
					this.daifudingjin() //  我的运单 -- 待确定
				} else if (indexnav == 1) {
					this.daibaojiao() //  我的运单 -- 待报价
				}
			},

			ckndex(e) {
				this.nandex = e
			},
			wzhankai(index) {
				// var yincang = this.wyincang
				// if (yincang == true) {
				// 	this.wyincang = false
				// 	this.wvheiget = "block"
				// } else if (yincang == false) {
				// 	this.wyincang = true
				// 	this.wvheiget = "none"
				// }
				this.navindexnav = index
			},
			ptjr() {
				this.notification = true
			},
			guanbi() {
				this.notification = false
				this.dianjixuanz = false
			},

			detailed(e) {
				var id = e.id
				uni.navigateTo({
					url: '/pages/Mywaybill/detailed?id=' + id
				})
			},



			guestbook() {
				uni.navigateTo({
					url: '/pages/guestbook/guestbook',
				})
			},

			//  我的运单 -- 待付订金 
			async daifudingjin() {
				var skipCount = this.skipCount
				var maxResultCount = this.maxResultCount
				try {
					const {
						data: res
					} = await GetWaybillList({
						skipCount,
						maxResultCount,
						status: 2,
						driverId: this.userId
					})
					this.lista = res.result.items
					this.xiugaiyunfei(e)
					this.xiugaidinjin(e)
					console.log(this.lista)
				} catch (e) {}
			},
			//修改运费
			async xiugaiyunfei(e) {
				var id = e.id
				var offer = e.amountTotal
				var deposit = 0
				try {
					const {
						data: res
					} = await UpdateDepFee({
						id,
						offer,
						deposit
					})
					if (res.result.message == 'ok') {
						uni.showToast({
							title: '运费修改成功',
							duration: 2000
						})
					}

				} catch (e) {}
			},
			//修改订金
			async xiugaidinjin(e) {
				var id = e.id
				var offer = 0
				var deposit = e.deposit
				try {
					const {
						data: res
					} = await UpdateDepFee({
						id,
						offer,
						deposit
					})
					if (res.result.message == 'ok') {
						uni.showToast({
							title: '订金修改成功',
							duration: 2000
						})
					}

				} catch (e) {}
			},

			//  我的运单 -- 运输中
			async yunshuzhong() {

				var skipCount = this.skipCount
				var maxResultCount = this.maxResultCount
				try {
					const {
						data: res
					} = await GetWaybillList({
						skipCount,
						maxResultCount,
						status: 6,
						driverId: this.userId
					})
					this.listb = res.result.items
					console.log('运输中', this.listb)
				} catch (e) {}

			},
			//我的运单--更改运输状态
			async genggaiyunshuzhong(id, tranStatus) {
				console.log(id)
				try {
					await TranStatusUpdate({
						id,
						tranStatus
					}).then((res)=>{
						var result = res.data.result
						console.log(result)
						if(result.success){
							this.yunshuzhong()
						}
						else{
							uni.showToast({
								title: result.message,
								icon: 'none',
							})
						}					
					})
					
				} catch (e) {}

			},

			//我的运单--上传
			shangchuan(e) {
				var waybillid = e
				console.log(waybillid)
				uni.navigateTo({
					url: "/pages/receipt/sjreceipt?id=" + waybillid,

				})
			},

			//  我的运单 -- 待结算
			async daijiesuan() {
				var skipCount = this.skipCount
				var maxResultCount = this.maxResultCount
				try {
					const {
						data: res
					} = await GetWaybillList({
						skipCount,
						maxResultCount,
						status: 3,
						driverId: this.userId
					})
					this.listc = res.result.items
					for (let i = 0; i < this.listc.length; i++) {
						if (this.listc[i].returnDeposit === false) {
							this.shows = false
						}
					}
				} catch (e) {}
			},


			//  我的运单 -- 已结算
			async yiwancheng() {
				var skipCount = this.skipCount
				var maxResultCount = this.maxResultCount
				try {
					const {
						data: res
					} = await GetWaybillList({
						skipCount,
						maxResultCount,
						status: 4,
						driverId: this.userId
					})
					this.listd = res.result.items
				} catch (e) {}
			},

			//  我的运单 -- 订单取消 -- 已成交
			async yichengjiao() {
				var skipCount = this.skipCount
				var maxResultCount = this.maxResultCount
				try {
					const {
						data: res
					} = await GetWaybillList({
						skipCount,
						maxResultCount,
						status: 5,
						isReceipt: 1,
						driverId: this.userId
					})
					this.liste = res.result.items
				} catch (e) {}
			},

			//  我的运单 -- 订单取消 -- 未成交
			async weichengjiao() {
				var skipCount = this.skipCount
				var maxResultCount = this.maxResultCount
				try {
					const {
						data: res
					} = await GetWaybillList({
						skipCount,
						maxResultCount,
						status: 5,
						isReceipt: 0,
						driverId: this.userId
					})
					this.listf = res.result.items
				} catch (e) {}
			},




			async queding() {
				var id = getValue('huozhuqix')
				var reason = this.reason
				var cancelBy = this.nandex
				try {
					const {
						data: res
					} = await WayBillCancel({
						id,
						reason,
						cancelBy
					})
					this.dianjixuanz = false
					this.daifudingjin() //  我的运单 -- 待确定
					this.daibaojiao() //  我的运单 -- 待报价
				} catch (e) {}
			},



			// 复制
			paste(value) {
				var fuzhi = value.waybillNumber
				uni.setClipboardData({
					data: fuzhi
				});
			},





			// 拨打电话
			bohao(item) {
				var phone = item.receiveTelphone
				uni.makePhoneCall({
					phoneNumber: phone,
					success: (res) => {
						this.CallRecordCreate();
					},
					fail: (res) => {
						console.log('打电话失败了');
					}
				})
			},

			// 创建通话记录
			async CallRecordCreate() {
				var waybillId = this.wayid
				var driverId = this.driverid
				var consignorId = this.shiperId
				
				try {
					const {
						data: res
					} = await CallRecordCreate({
						waybillId,
						driverId,
						consignorId
					})

				} catch (e) {}
			},


			// 创建交易订单
			async CreateTrade(item) {
				var payerUserId = item.driverId
				var amount = item.deposit
				var payDestination = 2
				var payType = 2
				var waybillId = item.id
				console.log(item)

				setValue('totalactFee', amount);
				try {
					const {
						data: res
					} = await CreateTrade({
						payerUserId,
						amount,
						payType,
						payDestination,
						waybillId
					})
					this.MiniProgramPay(res.result.data.tradeNumber)
				} catch (e) {}
			},
			async MiniProgramPay(res) {
				console.log(res, '11111111111111111')
				var outTradeNo = res
				var body = '订金支付'
				var talact = getValue('totalactFee')
				var totalFee = JSON.parse(talact * 100)
				var spBillCreateIp = '127.0.0.1'
				var notifyUrl = 'https://pay.syh56.com:44352/api/WeChatPayNotify/Unifiedorder'
				var tradeType = 'JSAPI'
				var openId = getValue('wxOpenId')
				uni.request({
					url: "https://pay.syh56.com:44352/api/WeChatPay/MiniProgramPay",
					method: "post",
					header: {
						'Abp.TenantId': '1',
						'Content-Type': "application/json",
					},
					data: {
						outTradeNo,
						body,
						totalFee,
						spBillCreateIp,
						notifyUrl,
						tradeType,
						openId
					},
					success: (res) => {
						var parameter = JSON.parse(res.data.parameter)
						this.doWxPay(parameter)
					}
				})
			},


			doWxPay(parameter) {
				var param = parameter
				//小程序发起微信支付
				uni.requestPayment({
					nonceStr: param.nonceStr,
					timeStamp: param.timeStamp, //记住，这边的timeStamp一定要是字符串类型的，不然会报错
					// out_trade_no: param.out_trade_no,
					appId: param.appId,
					package: param.package,
					signType: param.signType,
					paySign: param.paySign,
					success: function(event) {
						uni.showToast({
							title: '支付成功',
							icon: 'success',
							duration: 2000
						});
					},
					fail: function(error) {
						uni.showToast({
							title: '支付失败',
							icon: 'error',
							duration: 2000
						});
					},
					complete: function() {
						console.log("pay complete")
					}
				});
			},
			
			// 拨打客服电话
			bodakefu() {
				var phone = '85708887'
				uni.makePhoneCall({
					phoneNumber: phone,
					// success: (res) => {
					// 	this.CallRecordCreate(item);
					// },
					// fail: (res) => {
					// 	console.log('打电话失败了');
					// }
				})
			},
           
			// 搜索订单
			async kaishishous() {
				var keywords = this.sousuo
				var navIndex = this.navIndex
				var navndex = this.navndex
				var indexnav = this.indexnav
				var skipCount = this.skipCount
				var maxResultCount = this.maxResultCount
				// console.log(data)
				if (keywords == '') {
					uni.showToast({
						title: "搜索内容不能为空",
						icon: 'none',
						duration: 2000
					})
					return false
				}
				if (navIndex == 0) {
					if (indexnav == 0) {
						var status = 2
						var data = {
							skipCount,
							maxResultCount,
							status,
							keywords
						}
					} else if (indexnav == 1) {
						var status = 1
						var data = {
							skipCount,
							maxResultCount,
							status,
							keywords
						}
					}
				} else if (navIndex == 1) {
					var dStatus = 6
					var data = {
						skipCount,
						maxResultCount,
						dStatus,
						keywords
					}
				} else if (navIndex == 2) {
					var status = 3
					var data = {
						skipCount,
						maxResultCount,
						status,
						keywords
					}
				} else if (navIndex == 3) {
					var status = 4
					var data = {
						skipCount,
						maxResultCount,
						status,
						keywords
					}
				} else if (navIndex == 4) {
					if (navndex == 0) {
						var status = 5
						var isReceipt = 1
						var data = {
							skipCount,
							maxResultCount,
							status,
							isReceipt,
							keywords
						}
					} else if (navndex == 1) {
						var status = 5
						var isReceipt = 0
						var data = {
							skipCount,
							maxResultCount,
							status,
							isReceipt,
							keywords
						}
					}
				}
				// console.log(datac.toString())
				// var datat = datac.toString()
				// return false
				try {
					const {
						data: res
					} = await GetWaybillList(data)
					if (navIndex == 0) {
						if (indexnav == 0) {
							this.lista = res.result.items
						} else if (indexnav == 1) {
							this.listr = res.result.items
						}
					} else if (navIndex == 1) {
						this.listb = res.result.items
					} else if (navIndex == 2) {
						this.listc = res.result.items
					} else if (navIndex == 3) {
						this.listd = res.result.items
					} else if (navIndex == 4) {
						if (navndex == 0) {
							this.liste = res.result.items
						} else if (navndex == 1) {
							this.listf = res.result.items
						}
					}
				} catch (e) {}
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f7f7f7;
	}

	.screenshot {
		width: 100%;
		height: 100%;
		background-color: rgba(0, 0, 0, 0.4);
		position: fixed;
		top: 0;
		left: 0;
		z-index: 9999;

		.screenshot_key {
			width: 676.4upx;
			opacity: 1;
			background: #FFFFFF;
			box-shadow: 1.75upx 1.75upx 7.01upx 0px #e5e5e5;
			position: absolute;
			top: 50%;
			left: 50%;
			transform: translate(-50%, -50%);
			border-radius: 20upx;

			.image_top {
				position: absolute;
				top: 8upx;
				right: 48upx;
				width: 32upx;
				height: 32upx;
			}

			.screenshot_top {
				font-size: 32upx;
				text-align: center;
				padding: 37upx 0;
				border-bottom: 2upx solid #e5e5e5;
				font-weight: bold;
			}

			.screenshot_box {
				padding: 20upx 0 50upx 0;

				text {
					display: block;
					text-align: center;
					font-size: 28upx;
					color: #EF4D3D;
					padding-top: 30upx;
				}
			}

			.screenshot_list {
				padding: 48upx 0 35upx 44upx;
				border-bottom: 2upx solid #e5e5e5;

				text {
					display: block;
					font-size: 32upx;
					color: #EF4D3D;
					font-weight: bold;
				}

				view {
					display: inline-block;
					font-size: 24upx;
					color: #383838;
					line-height: 42upx;
					padding: 0 16upx;
					background-color: rgba(240, 77, 62, 0.1);
				}
			}

			.screensview {
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 50upx 40upx;

				view {
					image {
						width: 28upx;
						height: 28upx;
					}

					text {
						font-size: 32upx;
						font-weight: bold;
						padding-right: 28upx;
					}
				}
			}

			.screeiew {
				width: 190upx;
				height: 72upx;
				line-height: 72upx;
				font-size: 31upx;
				color: #fff;
				text-align: center;
				font-weight: bold;
				border-radius: 20upx;
				background-color: #EF4D3D;
				margin: 0 auto;
				margin-bottom: 46upx;
			}

			input {
				width: 90%;
				border: 2upx solid #e5e5e5;
				border-radius: 10upx;
				height: 80upx;
				margin: 0 auto;
				margin-bottom: 40upx;
				font-size: 24upx;
				padding: 0 20upx;
			}
		}
	}


	.search {
		border: 12upx solid #EF4D3D;
		border-radius: 20upx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 14upx 30upx;

		input {
			font-size: 24upx;
			width: 80%;
		}

		view {
			width: 96upx;
			height: 56upx;
			line-height: 56upx;
			text-align: center;
			border-radius: 20upx;
			background-color: #EF4D3D;
			font-size: 28upx;
			color: #fff;
		}
	}

	.container {
		padding: 0 15upx;

		.current {
			width: 100%;
			background-color: #fff;
			padding: 20upx;
			box-shadow: 1.75upx 1.75upx 7.01upx 0px #e5e5e5, 1.75upx 1.75upx 7.01upx 0px #e5e5e5;
			margin-top: 20upx;
			border-radius: 20upx;

			.current_top {
				display: flex;
				align-items: center;
				justify-content: space-between;

				.fl {
					font-size: 28upx;
					color: #000;
					font-weight: bold;
				}

				.fr {
					display: flex;
					align-items: center;

					text {
						font-size: 21upx;
						color: #a6a6a6;
						padding-right: 10upx;
					}

					image {
						width: 30upx;
						height: 30upx;
					}
				}
			}

			.current_box {
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding-top: 15upx;

				view {
					border-bottom: 4upx solid #fff;

					image {
						width: 47upx;
						height: 47upx;
						display: block;
						margin: 0 auto;
					}

					text {
						display: block;
						font-size: 22upx;
						color: #000;
						font-weight: bold;
						text-align: center;
						padding-top: 5upx;
					}
				}

				.active {
					border-bottom: 4upx solid #EF4D3D;
				}
			}
		}

		.success {
			width: 100%;
			background-color: #fff;
			padding: 25upx;
			box-shadow: 1.75upx 1.75upx 7.01upx 0px #e5e5e5, 1.75upx 1.75upx 7.01upx 0px #e5e5e5;
			margin-top: 20upx;
			border-radius: 20upx;
			position: relative;

			.retreat {
				position: absolute;
				top: 60upx;
				right: 42upx;
				width: 81upx;
				height: 81upx;
			}

			.success_top {
				display: flex;
				align-items: center;
				justify-content: space-between;

				.fl {
					display: flex;
					align-items: center;

					.viewtop {
						width: 96upx;
						height: 37upx;
						color: #fff;
						font-size: 22upx;
						background-color: #EF4D3D;
						text-align: center;
						line-height: 37upx;
					}

					.viewkey {
						font-size: 25upx;
						padding: 0 20upx;
						color: #383838;
					}

					.viewbox {
						width: 49upx;
						height: 26upx;
						border-radius: 8upx;
						background-color: #a6a6a6;
						text-align: center;
						line-height: 26upx;
						font-size: 17upx;
						color: #fff;
					}
					.viewboxs{
						border: 1px solid red;
						line-height: 25upx;
						font-size:18upx;
						color: #FFFFFF;
						background-color: #EF4D3D;
						border-radius: 10upx;
						margin-left: 20upx;
					}
				}

				.fr {
					font-size: 18upx;
					color: #a6a6a6;
					display: flex;
					align-items: center;

					text {
						font-size: 21upx;
					}

					image {
						width: 25upx;
						height: 25upx;
						margin-left: 20upx;
					}
				}
			}

			.success_key {
				.viewtop {
					display: flex;
					align-items: center;

					text {
						font-size: 28upx;
						color: #000;
						font-weight: bold;
						white-space: nowrap;
						overflow: hidden;
						text-overflow: ellipsis;
					}

					image {
						width: 96upx;
						height: 96upx;
					}
				}

				.viewbox {
					margin-top: -30upx;
					border-bottom: 1px solid rgba(229, 229, 229, 1);
					padding-bottom: 30upx;

					text {
						display: block;
						font-size: 21upx;
						color: #383838;
						padding-top: 10upx;
					}
				}
			}

			.success_one {
				p {
					font-size: 20upx;
					background-color: rgba(240, 77, 62, 0.1);
					margin-top: 10upx;
				}

				p:last-child {
					background-color: #FFFFFF;
					color: #EF4D3D;
					margin-bottom: 20upx;
					border-bottom: 1px solid rgba(229, 229, 229, 1);
					padding-bottom: 15upx;
				}

				image {
					width: 35upx;
					height: 35upx;
				}

				.yuan {
					font-size: 24upx;
					font-weight: 400;
					color: black;
				}

				.success_top {
					display: flex;
					justify-content: start;
					align-items: center;

					text {
						font-size: 25upx;
						font-weight: 600;
					}

					input {
						width: 100upx;
						text-align: center;
						color: #EF4D3D;
						font-size: 29upx;
						border-bottom: 1px solid #EF4D3D;
						font-weight: 600;
					}

					image {
						padding: 0upx 10upx;
					}

					text:nth-child(2) {
						color: #EF4D3D;
						padding: 5upx 10upx;

					}

					text:last-child {
						font-size: 22upx;
						;
						color: rgba(128, 128, 128, 1);
					}
				}

				.success_body {
					display: flex;
					align-items: center;

					text {
						font-size: 25upx;
						padding-top: -5upx;
					}

					text:nth-child(1) {
						font-weight: 600;

					}

					image {
						padding: 0upx 10upx;
					}

					input {
						width: 100upx;
						text-align: center;
						// color: #EF4D3D;
						font-size: 26upx;
						border-bottom: 1px solid #EF4D3D;
						font-weight: 600;
					}

					text:nth-child(2) {
						padding-left: 5upx;
						font-weight: 600;
					}

					text:nth-child(3) {
						font-weight: 600;
						padding: 0upx 5upx;
					}

					text:nth-child(4) {
						color: rgba(128, 128, 128, 1);
					}

					text:last-child {
						font-size: 22upx;
						;
						color: rgba(128, 128, 128, 1);
					}
				}

			}

			.contact {
				padding: 10upx 0 20upx;
				border-top: 2upx solid #E5E5E5;
				border-bottom: 2upx solid #E5E5E5;
				margin-top: 20upx;

				.contact_top {
					p {
						width: 240upx;
						margin-left: 260upx;
						font-size: 24upx;
						color: #EF4D3D;
					}

					view {
						display: flex;
						align-items: center;
						padding-top: 10upx;

						text {
							font-size: 28upx;
							color: #000;
							font-weight: bold;
						}

						.viewtop {
							color: #EF4D3D;
						}

						.viewbox {
							color: #808080;
							font-size: 24upx;
							width: 330upx;
						}
					}
				}

				.contact_key {
					line-height: 28upx;
					// display: inline-block;
					background-color: rgba(240, 77, 62, 0.1);
					font-size: 21upx;
				}

				.contact_box {
					line-height: 32upx;
					color: #EF4D3D;
					font-size: 24upx;
				}
			}

			.seperate {
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding-top: 18upx;

				.seperate_fl {
					display: flex;
					align-items: center;

					text {
						font-size: 24upx;
					}

					view {
						font-size: 24upx;
						color: #EF4D3D;
					}
				}

				.seperate_fr {
					font-size: 24upx;
					color: #EF4D3D;
				}
			}


			.descrip_top {
				margin-top: 20upx;
				height: 75upx;
				opacity: 1;
				background: #F0F0F0;
				padding: 0 40upx;
				display: flex;
				align-items: center;

				.box_box {
					width: 56upx;
					height: 56upx;
					opacity: 1;
					border-radius: 10upx;
					background: #FFC300;
					font-size: 38upx;
					font-weight: bold;
					color: #fff;
					text-align: center;
					line-height: 56upx;
				}

				.box_key {
					width: 56upx;
					height: 56upx;
					opacity: 1;
					border-radius: 10upx;
					background: #EF4D3D;
					font-size: 38upx;
					font-weight: bold;
					color: #fff;
					text-align: center;
					line-height: 56upx;
				}

				.descr_box {
					padding-left: 28upx;

					text {
						display: block;
						font-size: 22upx;
						color: #000;
					}
				}
			}

			.warn {
				display: flex;
				align-items: center;
				padding-top: 10upx;
				padding-left: 14upx;

				image {
					width: 26upx;
					height: 26upx;
				}

				text {
					font-size: 24upx;
					color: #000;
				}

				.warnkey {
					color: #EF4D3D;
					padding: 0 10upx;
				}
			}

			.group {
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding-top: 20upx;

				.group_fl {
					view {
						font-size: 21upx;
						font-weight: bold;
					}

					text {
						display: block;
						font-size: 14upx;
						color: #808080;
					}
				}

				.group_fr {
					width: 470upx;
					height: 53upx;
					border-radius: 10upx;
					background-color: #f7f5f5;
					padding: 0 25upx;
					font-size: 17upx;
					line-height: 53upx;
				}
			}

			.success_box {
				display: flex;
				align-items: center;
				justify-content: flex-end;
				padding-top: 35upx;

				view {
					width: 138upx;
					height: 48upx;
					border: 2upx solid #EF4D3D;
					line-height: 44upx;
					text-align: center;
					border-radius: 10upx;
					font-size: 26upx;
					color: #EF4D3D;
					font-weight: bold;
					margin-left: 20upx;
				}

				.viewtop {
					background-color: #EF4D3D;
					color: #fff;
					margin: 0 10upx;
				}
			}

			.success_bos {
				display: flex;
				align-items: center;
				justify-content: center;
			}

			.success_sj {
				display: flex;
				align-items: center;
				justify-content: start;
				position: absolute;
				margin-top: 20upx;

				image:first-child {
					width: 65upx;
					height: 65upx;
				}

				.success_sjs {
					display: flex;
					flex-direction: column;
					font-size: 24upx;
					margin-left: 20upx;

					text:last-child {
						color: #EF4D3D;
						margin-left: 25upx;
					}

					image {
						width: 25upx;
						height: 25upx;
						position: absolute;
						margin-top: 35upx;
					}
				}
			}
		}
	}


	.down {
		width: 250upx;
		height: 63upx;
		border-radius: 17upx;
		overflow: hidden;
		box-shadow: 1.75px 1.75px 7.01px 0px rgba(0, 0, 0, 0.25), 1.75px 1.75px 7.01px 0px rgba(0, 0, 0, 0.25);
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-top: 20upx;

		view {
			width: 50%;
			font-size: 28upx;
			font-weight: bold;
			text-align: center;
			border-radius: 17upx;
			height: 63upx;
			line-height: 63upx;
		}

		.active {
			background-color: #EF4D3D;
			color: #fff;
		}
	}

	.tancuang {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background-color: rgba(0, 0, 0, 0.5);
		z-index: 9999;

		.tancuang_key {
			width: 676upx;
			// height: 560upx;
			background-color: #fff;
			border-radius: 20upx;
			position: absolute;
			top: 50%;
			left: 50%;
			transform: translate(-50%, -50%);
			padding: 0 60upx 30upx;

			.tancuang_top {
				display: flex;
				align-items: center;
				padding-top: 20upx;

				view {
					width: 50%;
					text-align: center;
					font-size: 35upx;
					color: #808080;
				}

				.active {
					color: #EF4D3D;
				}
			}

			.tancuang_lis {
				width: 100%;
				padding: 0 70upx 25upx;
				background-color: #e6e6e6;
				margin-top: 26upx;

				view {
					display: flex;
					align-items: center;
					padding-top: 25upx;

					.fl {
						width: 28upx;
						height: 28upx;
						border-radius: 50%;
						background-color: #EF4D3D;
						font-size: 24upx;
						color: #fff;
						text-align: center;
						line-height: 28upx;
						margin-right: 40upx;
					}

					.fr {
						font-size: 29upx;
					}
				}
			}

			.text {
				font-size: 24upx;
				color: #383838;
				padding-top: 20upx;
			}

			.panel {
				width: 231upx;
				color: #fff;
				background-color: #EF4D3D;
				height: 72upx;
				text-align: center;
				line-height: 72upx;
				margin: 0 auto;
				border-radius: 10upx;
				font-size: 31upx;
				margin-top: 20upx;
			}
		}
	}

	.screenshots {
		width: 100%;
		height: 100%;
		background-color: rgba(0, 0, 0, 0.4);
		position: fixed;
		top: 0;
		left: 0;
		z-index: 9999;

		.screenshot_key {
			width: 720upx;
			height: 480upx;
			opacity: 1;
			background: #FFFFFF;
			box-shadow: 1.75upx 1.75upx 7.01upx 0px #e5e5e5;
			border-radius: 20upx;
			position: absolute;
			top: 50%;
			left: 50%;
			transform: translate(-50%, -50%);
			padding-top: 20upx;

			.image_top {
				width: 100upx;
				height: 100upx;
				margin: 0 auto;
				display: block;
				padding-top: 48upx;
			}

			.image_gb {
				width: 32upx;
				height: 32upx;
				position: absolute;
				top: 8upx;
				right: 48upx;
			}

			.screenshot_top {
				font-size: 28upx;
				color: #000;
				text-align: center;
				padding-top: 30upx;
			}

			.screenshot_box {
				font-size: 38upx;
				font-weight: bold;
				color: #000;
				text-align: center;
				padding-top: 20upx;
			}

			.screenshot_zhen {
				width: 601upx;
				height: 71upx;
				opacity: 1;
				border-radius: 17.52upx;
				background: #FFFFFF;
				line-height: 65upx;
				border: 3upx solid #F04D3E;
				font-size: 31.54upx;
				text-align: center;
				font-weight: bold;
				margin: 0 auto;
				margin-top: 50upx;
			}

			.screenshot_lis {
				font-size: 24upx;
				color: #808080;
				text-align: center;
				padding-top: 20upx;
			}

		}
	}
</style>
